function ret_val = extractFOA(rgb_img)
%get the saliency map for the image
sal_map = sal(rgb_img);
%convert to range [0..1]
sal_map = mat2gray(sal_map);
%get size
[v_size, h_size] = size(sal_map);
v_incr = v_size / 11;
h_incr = h_size / 11;

%objects in the center of the image get more weight
weight_mat = [0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8;
              0.8 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.8;
              0.8 0.9 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.9 0.8;
              0.8 0.9 1.0 1.1 1.1 1.1 1.1 1.1 1.0 0.9 0.8;
              0.8 0.9 1.0 1.1 1.2 1.2 1.2 1.1 1.0 0.9 0.8;
              0.8 0.9 1.0 1.1 1.2 1.3 1.2 1.1 1.0 0.9 0.8;
              0.8 0.9 1.0 1.1 1.2 1.2 1.2 1.1 1.0 0.9 0.8;
              0.8 0.9 1.0 1.1 1.1 1.1 1.1 1.1 1.0 0.9 0.8;
              0.8 0.9 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.9 0.8;
              0.8 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.8;
              0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8];

%create a 10x10 matrix of average saliency
for i=0:10,
  for j=0:10,
    h1 = (i * floor(h_incr)) + 1;
    h2 = ((i+1) * floor(h_incr));
    v1 = (j * floor(v_incr)) + 1;
    v2 = ((j+1) * floor(v_incr));
    tmp = sal_map(v1:v2, h1:h2);
    mean_mat(i+1, j+1) = mean(mean(tmp));
  end
end
%apply weight
mean_mat = mean_mat .* weight_mat;

foa_pixel = max_coords(mean_mat);
foa_pixel(1) = foa_pixel(1) * h_incr;
foa_pixel(2) = foa_pixel(2) * v_incr;

%extract the calculated salient part of the image
v_range1 = foa_pixel(2) - (0.25 * v_size);
v_range2 = foa_pixel(2) + (0.25 * v_size);
h_range1 = foa_pixel(1) - (0.25 * h_size);
h_range2 = foa_pixel(1) + (0.25 * h_size);

if v_range1 < 0
  v_range1 = 0;
end

if h_range1 < 0
  h_range1 = 0;
end

if v_range2 > v_size
  v_range2 = v_size;
end

if h_range2 > h_size
  h_range2 = h_size;
end

ret_val = rgb_img(v_range1:v_range2, h_range1:h_range2, :);
